package api

import (
	"360-cinema/api-getaway/basic/config"
	"360-cinema/api-getaway/basic/handler/request"
	__ "360-cinema/api-getaway/basic/videoProto"
	"github.com/gin-gonic/gin"
	"net/http"
)

func ListHistory(c *gin.Context) {
	var history request.History
	err := c.ShouldBind(&history)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "参数错误",
		})
		return
	}
	r, err := config.VideoClient.ListHistory(c, &__.ListHistoryReq{UserId: int64(history.UserId)})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "查询失败",
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"UserId":   r.UserId,
		"VideoId":  r.VideoId,
		"DramaId":  r.DramaId,
		"Progress": r.Progress,
	})

}
